<template>
  <sh-annex
    :attachmentConfigs="attachmentConfigs"
    :displayMode="annexData1.displayMode"
    :annexData="annexData1.templateSubVos"
    :beforeUpload="beforeUpload"
    :beforeDelete="onDelete"
    @uploadSuccess="uploadSuccess"
    @deleteSuccess="deleteSuccess"
  ></sh-annex>
</template>

<script setup>
import { annexData } from './data/annex';
import Img from '../../assets/logo.png';
import { reactive } from 'vue';
const attachmentConfigs = {
  showDown: true,
  showUpload: true,
  showDelete: true,
  showEmptySubclass: false,
  multiple: true,
};
const annexData1 = reactive({
  displayMode: '1',
  templateSubVos: [],
});
const annexData2 = [{
			"templateCode": "20001",
			"templateName": "生态中心-合作方信息管理",
			"categoryType": "2",
			"categoryCode": "ecologyBasicYyzz",
			"categoryName": "营业执照(必传)",
			"deleteOperation": 0,
			"downloadOperation": 1,
			"fileFormat": "jpg,png,jpeg,pdf,gif,excel,word",
			"fileMaximum": 5,
			"fileMaxSize": 20,
			"fileMinimum": 0,
			"mustQualified": 0,
			"mustRequire": 0,
			"uploadOperation": 1,
			"approveRemark": null,
			"approveStatus": null,
			"id": "2023004",
			"fileId": null,
			"fileName": null,
			"previewUrl": null,
			"systemFileFlag": null,
			"thumbnailUrl": null,
			"downloadUrl": null,
			"updateTime": "2023-04-14",
			"pCategoryCode": "ecologyBasic",
			"pCategoryName": "基本信息"
		}, {
			"templateCode": "20001",
			"templateName": "生态中心-合作方信息管理",
			"categoryType": "2",
			"categoryCode": "ecologyShareholderFrSfz",
			"categoryName": "法人身份证(必传)",
			"deleteOperation": 0,
			"downloadOperation": 1,
			"fileFormat": "jpg,png,jpeg,pdf,gif",
			"fileMaximum": 5,
			"fileMaxSize": 20,
			"fileMinimum": 0,
			"mustQualified": 0,
			"mustRequire": 0,
			"uploadOperation": 1,
			"approveRemark": null,
			"approveStatus": null,
			"id": "2023014",
			"fileId": null,
			"fileName": null,
			"previewUrl": null,
			"systemFileFlag": null,
			"thumbnailUrl": null,
			"downloadUrl": null,
			"updateTime": "2023-04-14",
			"pCategoryCode": "ecologyShareholder",
			"pCategoryName": "法人或股东信息"
		}, {
			"templateCode": "20001",
			"templateName": "生态中心-合作方信息管理",
			"categoryType": "2",
			"categoryCode": "ecologyCooperateInfoSqb",
			"categoryName": "申请表(必传)",
			"deleteOperation": 0,
			"downloadOperation": 1,
			"fileFormat": "jpg,png,jpeg,pdf,gif",
			"fileMaximum": 5,
			"fileMaxSize": 20,
			"fileMinimum": 0,
			"mustQualified": 0,
			"mustRequire": 0,
			"uploadOperation": 1,
			"approveRemark": null,
			"approveStatus": null,
			"id": "2023017",
			"fileId": null,
			"fileName": null,
			"previewUrl": null,
			"systemFileFlag": null,
			"thumbnailUrl": null,
			"downloadUrl": null,
			"updateTime": "2023-04-14",
			"pCategoryCode": "ecologyCooperateInfo",
			"pCategoryName": "合作信息"
		}, {
			"templateCode": "20001",
			"templateName": "生态中心-合作方信息管理",
			"categoryType": "2",
			"categoryCode": "ecologyCooperateInfoJdbg",
			"categoryName": "尽调报告(必传)",
			"deleteOperation": 0,
			"downloadOperation": 1,
			"fileFormat": "jpg,png,jpeg,pdf,gif",
			"fileMaximum": 5,
			"fileMaxSize": 20,
			"fileMinimum": 0,
			"mustQualified": 0,
			"mustRequire": 0,
			"uploadOperation": 1,
			"approveRemark": null,
			"approveStatus": null,
			"id": "2023018",
			"fileId": null,
			"fileName": null,
			"previewUrl": null,
			"systemFileFlag": null,
			"thumbnailUrl": null,
			"downloadUrl": null,
			"updateTime": "2023-04-14",
			"pCategoryCode": "ecologyCooperateInfo",
			"pCategoryName": "合作信息"
		}, {
			"templateCode": "20001",
			"templateName": "生态中心-合作方信息管理",
			"categoryType": "2",
			"categoryCode": "ecologyBasicYzbg",
			"categoryName": "验资报告(必传)",
			"deleteOperation": 0,
			"downloadOperation": 1,
			"fileFormat": "jpg,png,jpeg,pdf,gif",
			"fileMaximum": 5,
			"fileMaxSize": 20,
			"fileMinimum": 0,
			"mustQualified": 0,
			"mustRequire": 0,
			"uploadOperation": 1,
			"approveRemark": null,
			"approveStatus": null,
			"id": "2023006",
			"fileId": null,
			"fileName": null,
			"previewUrl": null,
			"systemFileFlag": null,
			"thumbnailUrl": null,
			"downloadUrl": null,
			"updateTime": "2023-04-14",
			"pCategoryCode": "ecologyBasic",
			"pCategoryName": "基本信息"
		}, {
			"templateCode": "20001",
			"templateName": "生态中心-合作方信息管理",
			"categoryType": "2",
			"categoryCode": "ecologyCooperateInfoHzxy",
			"categoryName": "合作协议(必传)",
			"deleteOperation": 0,
			"downloadOperation": 1,
			"fileFormat": "jpg,png,jpeg,pdf,gif",
			"fileMaximum": 5,
			"fileMaxSize": 20,
			"fileMinimum": 0,
			"mustQualified": 0,
			"mustRequire": 0,
			"uploadOperation": 1,
			"approveRemark": null,
			"approveStatus": null,
			"id": "2023019",
			"fileId": null,
			"fileName": null,
			"previewUrl": null,
			"systemFileFlag": null,
			"thumbnailUrl": null,
			"downloadUrl": null,
			"updateTime": "2023-04-14",
			"pCategoryCode": "ecologyCooperateInfo",
			"pCategoryName": "合作信息"
		}, {
			"templateCode": "20001",
			"templateName": "生态中心-合作方信息管理",
			"categoryType": "2",
			"categoryCode": "ecologyCooperateInfoOthers",
			"categoryName": "其他",
			"deleteOperation": 0,
			"downloadOperation": 1,
			"fileFormat": "jpg,png,jpeg,pdf,gif",
			"fileMaximum": 5,
			"fileMaxSize": 20,
			"fileMinimum": 0,
			"mustQualified": 0,
			"mustRequire": 0,
			"uploadOperation": 1,
			"approveRemark": null,
			"approveStatus": null,
			"id": "2023020",
			"fileId": null,
			"fileName": null,
			"previewUrl": null,
			"systemFileFlag": null,
			"thumbnailUrl": null,
			"downloadUrl": null,
			"updateTime": "2023-04-14",
			"pCategoryCode": "ecologyShareholder",
			"pCategoryName": "法人或股东信息"
		}, {
			"templateCode": "20001",
			"templateName": "生态中心-合作方信息管理",
			"categoryType": "2",
			"categoryCode": "ecologyShareholderFrSfz",
			"categoryName": "法人身份证(必传)",
			"deleteOperation": 0,
			"downloadOperation": 1,
			"fileFormat": "jpg,png,jpeg,pdf,gif",
			"fileMaximum": 5,
			"fileMaxSize": 20,
			"fileMinimum": 0,
			"mustQualified": 0,
			"mustRequire": 0,
			"uploadOperation": 1,
			"approveRemark": null,
			"approveStatus": "null",
			"id": "1649674967719727106",
			"fileId": "",
			"fileName": null,
			"previewUrl": "",
			"systemFileFlag": null,
			"thumbnailUrl": "",
			"downloadUrl": "",
			"updateTime": "2023-04-14",
			"pCategoryCode": "ecologyShareholder",
			"pCategoryName": "法人或股东信息"
		}, {
			"templateCode": "20001",
			"templateName": "生态中心-合作方信息管理",
			"categoryType": "2",
			"categoryCode": "ecologyCooperateInfoSqb",
			"categoryName": "申请表(必传)",
			"deleteOperation": 0,
			"downloadOperation": 1,
			"fileFormat": "jpg,png,jpeg,pdf,gif",
			"fileMaximum": 5,
			"fileMaxSize": 20,
			"fileMinimum": 0,
			"mustQualified": 0,
			"mustRequire": 0,
			"uploadOperation": 1,
			"approveRemark": null,
			"approveStatus": "null",
			"id": "1649676836097609729",
			"fileId": "group1/M00/00/03/wKhYIWRDjMyACeTvAAHdYgHo9iM268.png",
			"fileName": null,
			"previewUrl": "http://huaxia.dev.godsuy.com/group1/M00/00/03/wKhYIWRDjMyACeTvAAHdYgHo9iM268.png",
			"systemFileFlag": null,
			"thumbnailUrl": "http://huaxia.dev.godsuy.com/group1/M00/00/03/wKhYIWRDjMyACeTvAAHdYgHo9iM268.png",
			"downloadUrl": "http://huaxia.dev.godsuy.com/group1/M00/00/03/wKhYIWRDjMyACeTvAAHdYgHo9iM268.png",
			"updateTime": "2023-04-14",
			"pCategoryCode": "ecologyCooperateInfo",
			"pCategoryName": "合作信息"
		}, {
			"templateCode": "20001",
			"templateName": "生态中心-合作方信息管理",
			"categoryType": "2",
			"categoryCode": "ecologyCooperateInfoJdbg",
			"categoryName": "尽调报告(必传)",
			"deleteOperation": 0,
			"downloadOperation": 1,
			"fileFormat": "jpg,png,jpeg,pdf,gif",
			"fileMaximum": 5,
			"fileMaxSize": 20,
			"fileMinimum": 0,
			"mustQualified": 0,
			"mustRequire": 0,
			"uploadOperation": 1,
			"approveRemark": null,
			"approveStatus": "null",
			"id": "1649676836521234434",
			"fileId": "group1/M00/00/03/wKhYIWRDjM6AZYpZAANMZJkVJ7k312.png",
			"fileName": null,
			"previewUrl": "http://huaxia.dev.godsuy.com/group1/M00/00/03/wKhYIWRDjM6AZYpZAANMZJkVJ7k312.png",
			"systemFileFlag": null,
			"thumbnailUrl": "http://huaxia.dev.godsuy.com/group1/M00/00/03/wKhYIWRDjM6AZYpZAANMZJkVJ7k312.png",
			"downloadUrl": "http://huaxia.dev.godsuy.com/group1/M00/00/03/wKhYIWRDjM6AZYpZAANMZJkVJ7k312.png",
			"updateTime": "2023-04-14",
			"pCategoryCode": "ecologyCooperateInfo",
			"pCategoryName": "合作信息"
		}, {
			"templateCode": "20001",
			"templateName": "生态中心-合作方信息管理",
			"categoryType": "2",
			"categoryCode": "ecologyCooperateInfoHzxy",
			"categoryName": "合作协议(必传)",
			"deleteOperation": 0,
			"downloadOperation": 1,
			"fileFormat": "jpg,png,jpeg,pdf,gif",
			"fileMaximum": 5,
			"fileMaxSize": 20,
			"fileMinimum": 0,
			"mustQualified": 0,
			"mustRequire": 0,
			"uploadOperation": 1,
			"approveRemark": null,
			"approveStatus": "null",
			"id": "1649676836949053441",
			"fileId": "group1/M00/00/03/wKhYIWRDjNGAbqJnAAHdYgHo9iM635.png",
			"fileName": null,
			"previewUrl": "http://huaxia.dev.godsuy.com/group1/M00/00/03/wKhYIWRDjNGAbqJnAAHdYgHo9iM635.png",
			"systemFileFlag": null,
			"thumbnailUrl": "http://huaxia.dev.godsuy.com/group1/M00/00/03/wKhYIWRDjNGAbqJnAAHdYgHo9iM635.png",
			"downloadUrl": "http://huaxia.dev.godsuy.com/group1/M00/00/03/wKhYIWRDjNGAbqJnAAHdYgHo9iM635.png",
			"updateTime": "2023-04-14",
			"pCategoryCode": "ecologyCooperateInfo",
			"pCategoryName": "合作信息"
		}, {
			"templateCode": "20001",
			"templateName": "生态中心-合作方信息管理",
			"categoryType": "2",
			"categoryCode": "ecologyCooperateInfoOthers",
			"categoryName": "其他",
			"deleteOperation": 0,
			"downloadOperation": 1,
			"fileFormat": "jpg,png,jpeg,pdf,gif",
			"fileMaximum": 5,
			"fileMaxSize": 20,
			"fileMinimum": 0,
			"mustQualified": 0,
			"mustRequire": 0,
			"uploadOperation": 1,
			"approveRemark": null,
			"approveStatus": "null",
			"id": "1649676872994902018",
			"fileId": "group1/M00/00/03/wKhYIWRDjOyAMtB0AANMZJkVJ7k028.png",
			"fileName": null,
			"previewUrl": "http://huaxia.dev.godsuy.com/group1/M00/00/03/wKhYIWRDjOyAMtB0AANMZJkVJ7k028.png",
			"systemFileFlag": null,
			"thumbnailUrl": "http://huaxia.dev.godsuy.com/group1/M00/00/03/wKhYIWRDjOyAMtB0AANMZJkVJ7k028.png",
			"downloadUrl": "http://huaxia.dev.godsuy.com/group1/M00/00/03/wKhYIWRDjOyAMtB0AANMZJkVJ7k028.png",
			"updateTime": "2023-04-14",
			"pCategoryCode": "ecologyShareholder",
			"pCategoryName": "法人或股东信息"
		}, {
			"templateCode": "20001",
			"templateName": "生态中心-合作方信息管理",
			"categoryType": "2",
			"categoryCode": "ecologyBasicYzbg",
			"categoryName": "验资报告(必传)",
			"deleteOperation": 0,
			"downloadOperation": 1,
			"fileFormat": "jpg,png,jpeg,pdf,gif",
			"fileMaximum": 5,
			"fileMaxSize": 20,
			"fileMinimum": 0,
			"mustQualified": 0,
			"mustRequire": 0,
			"uploadOperation": 1,
			"approveRemark": null,
			"approveStatus": "null",
			"id": "1649677083100172290",
			"fileId": "group1/M00/00/03/wKhYIWRDjRyAL4nLAANMZJkVJ7k687.png",
			"fileName": null,
			"previewUrl": "http://huaxia.dev.godsuy.com/group1/M00/00/03/wKhYIWRDjRyAL4nLAANMZJkVJ7k687.png",
			"systemFileFlag": null,
			"thumbnailUrl": "http://huaxia.dev.godsuy.com/group1/M00/00/03/wKhYIWRDjRyAL4nLAANMZJkVJ7k687.png",
			"downloadUrl": "http://huaxia.dev.godsuy.com/group1/M00/00/03/wKhYIWRDjRyAL4nLAANMZJkVJ7k687.png",
			"updateTime": "2023-04-14",
			"pCategoryCode": "ecologyBasic",
			"pCategoryName": "基本信息"
		}, {
			"templateCode": "20001",
			"templateName": "生态中心-合作方信息管理",
			"categoryType": "2",
			"categoryCode": "ecologyBasicYyzz",
			"categoryName": "营业执照(必传)",
			"deleteOperation": 0,
			"downloadOperation": 1,
			"fileFormat": "jpg,png,jpeg,pdf,gif",
			"fileMaximum": 5,
			"fileMaxSize": 20,
			"fileMinimum": 0,
			"mustQualified": 0,
			"mustRequire": 0,
			"uploadOperation": 1,
			"approveRemark": null,
			"approveStatus": "null",
			"id": "1649678497658556418",
			"fileId": "group1/M00/00/03/wKhYIWRDjmyAZoulAAHdYgHo9iM561.png",
			"fileName": null,
			"previewUrl": "http://huaxia.sit.godsuy.com/group1/M00/00/14/wKhYIWR0A_-APIdJAAE32MJfKKM278.jpg",
			"systemFileFlag": null,
			"thumbnailUrl": "http://huaxia.sit.godsuy.com/group1/M00/00/14/wKhYIWR0A_-APIdJAAE32MJfKKM278.jpg",
			"downloadUrl": "http://huaxia.sit.godsuy.com/group1/M00/00/14/wKhYIWR0A_-APIdJAAE32MJfKKM278.jpg",
			"updateTime": "2023-04-14",
			"pCategoryCode": "ecologyBasic",
			"pCategoryName": "基本信息"
		}]
setTimeout(() => {
  annexData1.templateSubVos = annexData2;
  console.log('setTimeout', annexData1.templateSubVos);
}, 100);

/**
 * @description 批量上传文件
 * @param files 文件<Array>
 * @returns Promise<unknown>
 */
const beforeUpload = (files, category) => {
  const res = files.map(item => {
    return {
        "path": "group1/M00/00/60/wKhYIWUCYkmAdJ_-AAAYTXwNwvM23.xlsx",
        "previewUrl": "http://huaxia.sit.godsuy.com/group1/M00/00/60/wKhYIWUCYkmAdJ_-AAAYTXwNwvM23.xlsx",
        "thumbnailUrl": "http://huaxia.sit.godsuy.com/group1/M00/00/60/wKhYIWUCYkmAdJ_-AAAYTXwNwvM23.xlsx",
        "downloadUrl": "http://huaxia.sit.godsuy.com/group1/M00/00/60/wKhYIWUCYkmAdJ_-AAAYTXwNwvM23.xlsx",
        "fileName": "银行流水测试.xlsx"
    };
  });
  const status = '200';
  return new Promise((resolve, reject) => {
    if (status == 200) {
      resolve(res);
    } else {
      reject('错误');
    }
  });
};
/**
 * @description: 保存附件关系
 */

/**
 * @description: 删除文件
 * @param: file 删除的文件
 * @returns: Promise<unknown>
 */
const onDelete = file => {
  console.log('beforeDelete', file);
  return getName({ userName: '', mobile: '' });
};

const uploadSuccess = files => {
  console.log(files);
};
const deleteSuccess = files => {
  console.log(files);
};
</script>
